using Andromeda.Global.Business.DataObject;
using ForgeIt.Dal.dbo;
using System;

using System.Collections.Generic;
using System.Linq;
using Andromeda.Global.Data;

namespace ForgeIt.Business.Stub
{
	public abstract class ContactStub : DataObjectModelBase
	{
		#region private fields


		private DBContact foDBContact;

        private Entity localIdEntity;

        private ContactType localIdContactType;


		#endregion private fields
    
		#region public constructors

		protected ContactStub()
			: this(new DBContact())
		{
		}

        protected ContactStub(Entity foIdEntity, ContactType foIdContactType)
          :this()
        {
            SetIdEntity(foIdEntity);
            SetIdContactType(foIdContactType);
        }

        protected ContactStub(Entity foIdEntity)
          :this()
        {
            SetIdEntity(foIdEntity);
        }

        protected ContactStub(ContactType foIdContactType)
          :this()
        {
            SetIdContactType(foIdContactType);
        }

		#endregion public constructors
    

		#region internal constructors

		internal ContactStub(DBContact foDBContact)
		{

			this.foDBContact = foDBContact;

		}

		#endregion internal constructors
  

		#region protected datasource properties
		

		internal DBContact DB_DBContact
		{
			get { return foDBContact ?? (foDBContact = new DBContact()); }
		}

		
		public override DataConnectorCollection DataObjects
		{
			get
			{
				return new DataConnectorCollection { foDBContact } ;
			}
		}

		

		/// 
		///
		/// 
		public int IdContact
		{
			get { return DB_DBContact.IdContact; }

		}

		/// 
		///
		/// 
		public int IdEntity
		{
			get { return DB_DBContact.IdEntity; }

			set { DB_DBContact.IdEntity = value; }

		}

		/// 
		///
		/// 
		public string ContactInfo
		{
			get { return DB_DBContact.ContactInfo; }

			set { DB_DBContact.ContactInfo = value; }

		}

		/// 
		///
		/// 
		public int IdContactType
		{
			get { return DB_DBContact.IdContactType; }

			set { DB_DBContact.IdContactType = value; }

		}

		#endregion protected datasource properties
    
		#region protected datasource foreign key properties
    

		///<summary>
		/// Getter method for obtainin a foreign key <see cref="Entity"/> object related to this object
		///</summary>
		public virtual Entity GetIdEntity()
		{
          return localIdEntity ?? (localIdEntity = new Entity(foDBContact.GetFK_IdEntity()));
		}
    

  		///<summary>
  		/// Setter method for linking this object to a foreign key object
  		///</summary>
  		///<param name="item">The <see cref="Entity"/> object to which we want to link our IdEntity</param>
  		public virtual void SetIdEntity(Entity item)
        {
          foDBContact.SetFK_IdEntity(item.DB_DBEntity);
          localIdEntity = new Entity(foDBContact.GetFK_IdEntity());
        }

		///<summary>
		/// Getter method for obtainin a foreign key <see cref="ContactType"/> object related to this object
		///</summary>
		public virtual ContactType GetIdContactType()
		{
          return localIdContactType ?? (localIdContactType = new ContactType(foDBContact.GetFK_IdContactType()));
		}
    

  		///<summary>
  		/// Setter method for linking this object to a foreign key object
  		///</summary>
  		///<param name="item">The <see cref="ContactType"/> object to which we want to link our IdContactType</param>
  		public virtual void SetIdContactType(ContactType item)
        {
          foDBContact.SetFK_IdContactType(item.DB_DBContactType);
          localIdContactType = new ContactType(foDBContact.GetFK_IdContactType());
        }

  
		#endregion protected datasource foreign key properties
    
		#region protected datasource external key properties
    

  
		#endregion protected datasource external key properties
    
		#region properties
    

		#endregion properties
    
		#region methods methods

		#endregion methods

        #region Static Factories

        public static Contact GetContact(int foIdContact)
        {
          return new Contact(DBContact.GetEntity(foIdContact));
        }
  
        public static IEnumerable<Contact> ListContact()
        {
            return (from DBContact entity in DBContact.ListEntity() select new Contact(entity));
        }
        
  
        public static IEnumerable<Contact> ListContact(object foIdContact, object foIdEntity, object foContactInfo, object foIdContactType)
        {
            return (from DBContact entity in DBContact.ListEntity(foIdContact, foIdEntity, foContactInfo, foIdContactType) select new Contact(entity));
        }
        
        #endregion Static List Methods

	
  }
}